package com.li.test.leetcode;

import java.util.Arrays;

public class HarfAsc {
    public static void main(String[] args) {
        int[] array =new int[]{5,3,33,1,33,888,34,2};
        Arrays.sort(array);

        //查找5的位置
        //二分查找法
        int tag = 5;
        int start=0;int end =array.length; //用来存放
        for(int i=0;i<array.length;i++){
            int c =(start+end)/2;
            if(array[c]>5){
                end =c;
            }else if(array[c]==5){
                System.out.println("输出位置:"+c);
                break;
            }else if(array[c]<5){
                start=c;
            }
        }
    }
}
